package org.huzhp.data.core;

import java.util.HashMap;
import java.util.Map;

/**
 * @Description: 数据库类型
 * @Author: huzp
 * @CreateDate: 2020/4/23 14:50
 * @Version: 1.0
 */
public enum DbType {

    MYSQL("MYSQL",3306,"jdbc:mysql://{IP}:{PORT}/{NAME}?serverTimezone=UTC"),
    ORACLE("ORACLE",1521,"jdbc:oracle:thin:@{IP}:{PORT}:{NAME}"),
    SQLSERVER("SQLSERVER",1433,"jdbc:microsoft:sqlserver://{IP}:{PORT};DatabaseName={NAME}"),
    SYBASE("SYBASE",5007,"jdbc:sybase:Tds:{IP}:{PORT}/{NAME}"),
    POSTGRESQL("POSTGRESQL",5432,"jdbc:postgresql://{IP}:{PORT}/{NAME}"),
    DB2("DB2",5432,"jdbc:db2://{IP}:{PORT}/{NAME}"),
    ;

    private static Map<String,DbType> types = new HashMap();

    static {
        for (DbType type: values()){
            types.put(type.getName(),type);
        }
    }

    public static Map<String, DbType> getTypes() {
        return types;
    }

    private String name;

    private Integer port;

    private String url;

    DbType( String name,Integer port, String url) {
        this.name = name;
        this.port = port;
        this.url = url;
    }

    public String getName() {
        return name;
    }

    public Integer getPort() {
        return port;
    }

    public String getUrl() {
        return url;
    }
}
